<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta content='width=device-width, initial-scale=1.0' name='viewport'>
    <meta content='' name='description'>
    <meta content='Nils Nordman' name='author'>
    <link href='/images/howl.png' rel='shortcut icon'>
    <title>Howl :: howl.ui.Selection</title>
    <link href="/stylesheets/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/syntax.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/howl.css" media="screen" rel="stylesheet" type="text/css" />
    <link href='//fonts.googleapis.com/css?family=Josefin+Slab' rel='stylesheet' type='text/css'>
    <link href='//fonts.googleapis.com/css?family=Open+Sans+Condensed:700' rel='stylesheet' type='text/css'>
  </head>
  <body class='doc doc_api doc_api_ui doc_api_ui_selection'>
    <div class='container'>
      <div class='masthead'>
        <ul class='nav nav-pills'>
          <li>
            <a href='/'>
              <span class='glyphicon glyphicon-home'></span>
              Home
            </a>
          </li>
          <li>
            <a href='/doc/'>
              <span class='glyphicon glyphicon-book'></span>
              Documentation
            </a>
          </li>
          <li>
            <a href='/blog/'>
              <span class='glyphicon glyphicon-bullhorn'></span>
              Blog
            </a>
          </li>
          <li>
            <a href='/contact.html'>
              <span class='glyphicon glyphicon-inbox'></span>
              Contact
            </a>
          </li>
        </ul>
      </div>
      <ol class="breadcrumb"><li><a href="/">Home</a></li><li><a href='../../'>Howl 0.3 Documentation</a></li><li>Api</li><li>Ui</li><li>howl.ui.Selection</li></ol>
      <h1 id="howl.ui.selection">howl.ui.Selection</h1>    <div class="toc">
      <div class="toc-title">
        <span>howl.ui.Selection</span>
      </div>
      <div class="toc-entries">
<div class="toc-group">
<a href="#overview" class="toc-group-header overview">Overview</a>
</div>
<div class="toc-group">
<a href="#properties" class="toc-group-header properties">Properties</a>
<li class=""><a href="#anchor">anchor</a></li>
<li class=""><a href="#cursor">cursor</a></li>
<li class=""><a href="#empty">empty</a></li>
<li class=""><a href="#includes_cursor">includes_cursor</a></li>
<li class=""><a href="#text">text</a></li>
<li class=""><a href="#persistent">persistent</a></li>
</div>
<div class="toc-group">
<a href="#methods" class="toc-group-header methods">Methods</a>
<li class=""><a href="#copy">copy </a></li>
<li class=""><a href="#cut">cut </a></li>
<li class=""><a href="#range">range </a></li>
<li class=""><a href="#remove">remove </a></li>
<li class=""><a href="#set">set </a></li>
<li class=""><a href="#select">select </a></li>
<li class=""><a href="#select_all">select_all </a></li>
</div>
</div>
</div>
&#x000A;&#x000A;<h2 id="overview">Overview</h2>&#x000A;&#x000A;<p>A selection is associated with a particular <a href="editor.html">Editor</a>, and represents the&#x000A;selection for that editor. It provides operations for obtaining information&#x000A;about and manipulating the selection. You would never create a Selection&#x000A;instance yourself; instead you access a selection instance through&#x000A;<a href="editor.html#selection">Editor.selection</a>.</p>&#x000A;&#x000A;<p><em>See also</em>:</p>&#x000A;&#x000A;<ul>&#x000A;<li>The <a href="../../spec/ui/selection_spec.html">spec</a> for Selection</li>&#x000A;<li>The documentation for the <a href="../clipboard.html">clipboard</a> module</li>&#x000A;</ul>&#x000A;&#x000A;<h2 id="properties">Properties</h2>&#x000A;&#x000A;<h3 id="anchor">anchor</h3>&#x000A;&#x000A;<p>The starting point of the selection. If the selection is <a href="#empty">empty</a>, it contains&#x000A;the current cursor position. Assigning to this would create a new selection,&#x000A;ranging from the assigned position to the cursor&rsquo;s current position.</p>&#x000A;&#x000A;<h3 id="cursor">cursor</h3>&#x000A;&#x000A;<p>The ending point of the selection, which is the same as the current cursor&#x000A;position. The character pointed at by cursor is not typically part of the&#x000A;selection. Assigning to this would manipulate an existing selection.</p>&#x000A;&#x000A;<h3 id="empty">empty</h3>&#x000A;&#x000A;<p>True if the selection is empty, and false otherwise.</p>&#x000A;&#x000A;<h3 id="includes_cursor">includes_cursor</h3>&#x000A;&#x000A;<p>A selection does not typically include the character pointed at by&#x000A;<a href="#cursor">cursor</a>. If <code>includes_cursor</code> is set to true, this is changed&#x000A;so that the selection always includes the cursor. Default is <code>false.</code></p>&#x000A;&#x000A;<h3 id="text">text</h3>&#x000A;&#x000A;<p>The text of the current selection, or <code>nil</code> if the selection is <a href="#empty">empty</a>.&#x000A;Assigning to this property causes the currently selected text to be replaced&#x000A;with the assigned string and the selection to be removed.</p>&#x000A;&#x000A;<h3 id="persistent">persistent</h3>&#x000A;&#x000A;<p>A boolean specifying whether the selection is persistent or not. A persistent&#x000A;selection is automatically extended along with cursor movements, while a&#x000A;non-persistent selection would be removed upon any cursor movement.</p>&#x000A;&#x000A;<h2 id="methods">Methods</h2>&#x000A;&#x000A;<h3 id="copy">copy <span class="arg-list">(clip_options = {}, clipboard_options)</span></h3>&#x000A;&#x000A;<p>Copies the current selection to the <a href="../clipboard.html">clipboard</a>. If the selection was marked as&#x000A;<a href="#persistent">persistent</a>, it will be marked as non-persistent as a result of&#x000A;this call. The <code>selection-copied</code> signal is fired as a result of this call.</p>&#x000A;&#x000A;<p>The optional <code>clip_options</code> can specify additional fields for the clipboard&#x000A;item, and <code>clipboard_options</code> any additional options to be passed along to&#x000A;<a href="../clipboard.html#push">clipboard.push</a>.</p>&#x000A;&#x000A;<h3 id="cut">cut <span class="arg-list">(clip_options = {}, clipboard_options)</span></h3>&#x000A;&#x000A;<p>Cuts the current selection to the <a href="../clipboard.html">clipboard</a>. If the selection was marked as&#x000A;<a href="#persistent">persistent</a>, it will be marked as non-persistent as a result of&#x000A;this call. The <code>selection-cut</code> signal is fired as a result of this call.</p>&#x000A;&#x000A;<p>The optional <code>clip_options</code> can specify additional fields for the clipboard&#x000A;item, and <code>clipboard_options</code> any additional options to be passed along to&#x000A;<a href="../clipboard.html#push">clipboard.push</a>.</p>&#x000A;&#x000A;<h3 id="range">range <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Returns the start and stop offsets for the selection in ascending order, or&#x000A;<code>nil</code> if the selection is <a href="#empty">empty</a>.</p>&#x000A;&#x000A;<h3 id="remove">remove <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Removes the selection. Note that this does not remove any content - it&rsquo;s only&#x000A;the selection itself that is removed. If the selection was marked as&#x000A;<a href="#persistent">persistent</a>, it will be marked as non-persistent as a result of this call.</p>&#x000A;&#x000A;<h3 id="set">set <span class="arg-list">(anchor, cursor)</span></h3>&#x000A;&#x000A;<p>Sets the selection, <code>anchor</code> and <code>cursor</code> in one call.</p>&#x000A;&#x000A;<h3 id="select">select <span class="arg-list">(anchor, pos)</span></h3>&#x000A;&#x000A;<p>Sets the selection so that the range of characters specified by <code>anchor</code> and&#x000A;<code>pos</code> are all included in the selection.</p>&#x000A;&#x000A;<h3 id="select_all">select_all <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Selects all the text in the associated editor.</p>
      <div class='footer text-muted'>
        <a href='/'>
          <img width="50" height="50" class="footer-logo" src="/images/howl.png" />
        </a>
        <div class='footer-follow'>
          <p>
            <a class='twitter-follow-button' data-lang='en' data-show-count='false' href='https://twitter.com/howleditor' rel='me'>
              Follow @howleditor
            </a>
          </p>
          <p>
            <a class='twitter-share-button' data-count='none' data-hashtags='howleditor' data-lang='en' data-text='The Howl Editor, a general purpose, light-weight customizable editor.' data-url='http://howl.io' href='https://twitter.com/share'>
              Tweet
            </a>
          </p>
        </div>
        <div class='footer-blurb'>
          <div>The Howl editor.</div>
          <div>
            Copyright 2012-2015
            <a class='alert-link' href='https://github.com/nilnor/howl/contributors'>
              The Howl Developers.
            </a>
          </div>
        </div>
      </div>
    </div>
    <script>
      <!-- / GA -->
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-45283282-1', 'howl.io');
      ga('send', 'pageview');
      <!-- / Twitter -->
      !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
      if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
      js.src="//platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
  </body>
</html>
